#ifndef _CTRL_CENETER
#define _CTRL_CENETER

#pragma once
#include "Wlheadfile.h"
#include "ListManage.h"
#include "DataFormatManage.h"
#include "TcpCommunication.h"
#include "BufferQueue.h"
#include "UdpIocp.h"
#include "SampointsManage.h"
#include "XMLManage.h"
class CCtrlCenter:public CUdpIocp,public CListManage,public CBufferQueue,public CTcpCommunication
{
public:
	CCtrlCenter(void);
	~CCtrlCenter(void);
	
	///////////////////////////////////////////
	void RecvUdpIocpData(char* pRecvData,int nLength,unsigned long ulIp,int nPort);


	void EngineConnAp(const LPAP_NODE lpApNode);

	void EngineSendApHeart(const LPAP_NODE lpApNode);

	void GetRssiFromTimeOut(LP_QUEUE_NODE lpNode);


	void GetQueueData(LP_QUEUE_NODE lpNode,int nIndex);

	void ReleaseQueueData(LP_QUEUE_NODE lpNode,int nIndex);


	bool RecvTcpData(char* &pBuffer,int &nSpace,int &nLocation);

	////////////////////////////////////////////

	void StartEngine();

	void EndEngine();

private:

	//CListManage m_oListManage;

	CXMLManage m_oXmlManage;

	CDataFormatManage m_oDataFormatManage;

	CSampointsManage m_oSampointManage;

	bool m_bStartRecvTcp;

	char *m_pRecvTcpBuffer;

	LPXMLPACKHEAD lpXmlPackHead;

	LP_QUEUE_NODE lpCmdQueueNode;

	void RecvTcpCmd();

	bool checkMapGroup(LPVRSSI_MAP_GROUP lpRMapGroup,LPRSSI_MAP_GROUP &lpRssiMapGroup,string str);

	bool checkSignalGroup(LPVRSSI_SIGNAL_GROUP lpRSignalGroup,LPRSSI_SIGNAL_GROUP &lpRssiSignal,PVOID pSignal);

	inline void AddNewSignalGroup(LPRSSI_MAP_GROUP lpRssiMapGroup, LPRSSI_LIST lpRssiList);

	void GetFirstThreadQueueData(LP_QUEUE_NODE lpNode);

	void GetSecondThreadQueueData(LP_QUEUE_NODE lpNode);

	void SelectMapFormQueueData(LP_QUEUE_NODE lpNode);

	inline void SendDataToUi(char* pSendBuffer);
};
#endif